#!/bin/bash
set -e
set -u

module="scrull"
device="scrull"
mode="644"

insmod ./${module}.ko $* || exit 1

rm -f /dev/${device}[0-3]

major=$(awk "\$2==\"$module\" {print \$1}" /proc/devices)
echo "major: ${major}"

mknode /dev/${device}0 c $major 0
mknode /dev/${device}1 c $major 1
mknode /dev/${device}2 c $major 2
mknode /dev/${device}3 c $major 3

group="staff"
grep -q '^staff:' /etc/group || group="wheel"

chgrp $group /dev/${device}[0-3]
chmod $mode /dev/${device}[0-3]

